import 'package:dio/dio.dart';
import './http_response.dart';

abstract class HttpTransformer {
  HttpResponse parse(Response response);
}

class DefaultHttpTransformer extends HttpTransformer {
  @override
  HttpResponse parse(Response response) {
    // if (response.data["status"] == 200) {
    //   return HttpResponse.success(response.data["data"]);
    // } else if (response.data["code"] == 1 && response.data["msg"] == "success") {
    //   return HttpResponse.success(response.data["data"]);
    // } else {
    //   return HttpResponse.failure(errorMsg: response.data["message"], errorCode: response.data["code"]);
    // }
    return HttpResponse.success(response.data);
  }
  //
  static DefaultHttpTransformer _instance = DefaultHttpTransformer._internal();
  DefaultHttpTransformer._internal();
  factory DefaultHttpTransformer.getInstance() => _instance;
}